package com.ruoyi.group.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.group.domain.listPage;
import com.ruoyi.group.service.IlistPageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单列表Controller
 * 
 * @author yb
 * @date 2022-03-12
 */
@RestController
@RequestMapping("/listPage/listPage")
public class listPageController extends BaseController
{
    @Autowired
    private IlistPageService listPageService;

    /**
     * 查询工单列表列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:list')")
    @GetMapping("/list")
    public TableDataInfo list(listPage listPage)
    {
        startPage();
        List<listPage> list = listPageService.selectlistPageList(listPage);
        return getDataTable(list);
    }

    /**
     * 导出工单列表列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:export')")
    @Log(title = "工单列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, listPage listPage)
    {
        List<listPage> list = listPageService.selectlistPageList(listPage);
        ExcelUtil<listPage> util = new ExcelUtil<listPage>(listPage.class);
        util.exportExcel(response, list, "工单列表数据");
    }


    /**
     * 获取工单列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:query')")
    @GetMapping(value = "/{repairId}")
    public AjaxResult getInfo(@PathVariable("repairId") Integer repairId)
    {
        return AjaxResult.success(listPageService.selectlistPageByRepairId(repairId));
    }

    /**
     * 新增工单列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:add')")
    @Log(title = "工单列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody listPage listPage)
    {
        return toAjax(listPageService.insertlistPage(listPage));
    }

    /**
     * 修改工单列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:edit')")
    @Log(title = "工单列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody listPage listPage)
    {
        return toAjax(listPageService.updatelistPage(listPage));
    }
    /**
     * 回复工单详情列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:edit')")
    @Log(title = "工单列表", businessType = BusinessType.OTHER)
    @PostMapping("/reply")
    public AjaxResult reply(@RequestBody listPage listPage){
        return toAjax(listPageService.findPage(listPage));
    }
    /**
     * 删除工单列表
     */
    @PreAuthorize("@ss.hasPermi('listPage:listPage:remove')")
    @Log(title = "工单列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairIds}")
    public AjaxResult remove(@PathVariable Integer[] repairIds)
    {
        return toAjax(listPageService.deletelistPageByRepairIds(repairIds));
    }
}
